/**
 * Include Standard Libraries
**/
#include <iostream>

/**
 * Include helper functions
**/
#include <arguments.h>
#include <programinfo.h>

/**
 * Include the various library interfaces
**/
#include <interface_lua.h>
#include <interface_irrlicht.h>

/**
 * The program entry point
**/
int main( int argc, const char * argv[] )
{
    switch(parse_args(argc, argv))
    {
        case PROGRAM_STATE_DISPLAY_VERSION:
            std::cout << get_version() << std::endl;
            return 0;
        case PROGRAM_STATE_DISPLAY_HELP:
            std::cout << get_version() << std::endl << std::endl;
            std::cout << get_purpose() << std::endl << std::endl;
            std::cout << get_usage()   << std::endl << std::endl;
            return 0;
        case PROGRAM_STATE_EXIT:
            return PROGRAM_STATE_EXIT;
        case PROGRAM_STATE_CONTINUE:
            break;
    }

    /**
     * If we haven't been passed a script to launch from, assume 'scripts/main.lua'
    **/
    if ( param_baseScript[0] == '\0' )
    {
        strcpy(param_baseScript,"scripts/main.lua");
    }

    LuaInterface      lua;
    IrrlichtInterface::registerMe(lua);

    if (!lua.loadScript(param_baseScript))
    {
        std::cerr << "Exit on error" << std::endl;
        return 0;
    }

    return 0;
}
